
# -*- coding: UTF-8 -*-
import re
# class Employee:
#     '所有员工的基类'
#     empCount = 0
#
#     def __init__(self, name, salary):
#         self.name = name
#         self.salary = salary
#         Employee.empCount += 1
#
#     def displayCount(self):
#         print "Total Employee %d" % Employee.empCount
#
#     def displayEmployee(self):
#         print "Name : ", self.name, ", Salary: ", self.salary
#
#
# "创建 Employee 类的第一个对象"
# emp1 = Employee('Zara', 2000)
# "创建 Employee 类的第二个对象"
# emp2 = Employee('Manni', 5000)
# emp3 = Employee('张三', 6000)
# setattr(emp1,'age',18)
# emp1.displayEmployee()
# emp2.displayEmployee()
# emp3.displayEmployee()
# print "Total Employee %d" % Employee.empCount
# print "Employee.__doc__:", Employee.__doc__
# print "Employee.__name__:", Employee.__name__
# print "Employee.__module__:", Employee.__module__
# print "Employee.__bases__:", Employee.__bases__
# print "Employee.__dict__:", Employee.__dict__


# 正则表达式
print(re.match('www', 'www.runoob.com').span())  # 在起始位置匹配
print(re.match('com', 'www.runoob.com'))         # 不在起始位置匹配
print (';;;;;')


patter = re.compile(r'hello word !!')
match1 = patter.match('hello word !!   today is  good day!')
if match1:
    print (match1.group())
else:
    print ('match1匹配失败')

a = re.search(r'(tina)(fei)haha','tinafeihahafei tinafeihahatina').group()
b = re.search(r'(tina)(fei)haha\1','tinafeihahafei tinafeihahatina').group()
c = re.search(r'(tina)(fei)haha\2','tinafeihahafei tinafeihahatina').group()
d = re.search(r'.' ,  'a c \n sfsd#$#$').group()
print(a)
print(b)
print(c)
print(d)
print ("----------")
tt = "Tina is a good girl, she is cool, clever, and so on..."
rr = re.compile(r'\w*oo\w*')
print(rr.findall(tt))   #查找所有包含'oo'的单词

w = re.findall(r'\bt','tian tinaaaa')
print(w)
s = re.findall(r'\btin','tina tinaaaa')
print(s)
v = re.findall(r'\btian\b','tian#tianaaa')
print(v)
a = re.findall(r'\wtinaHBG','tSDFSDtinaHBGGian#tina@aaa')
print(a)
a0 = re.findall(r'\WSD%!!!!!!','SD%!!!!!!DFSDtinaHBGGian#tina@aaa')
print(a0)
a1 = re.findall(r'\A154','154DSFDREW')
print(a1)
a2 = re.findall(r'\ZREW','154DSFDREW')
print(a2)
a3 = re.findall(r'^\babd','154abDSFDREW')
print(a3)

b0 = re.findall(r'\w*a\w*','tinacc #tinam @aaa')
print(b0)
b01 = re.findall(r'\d','0lj5t121548548inacc #tinam @aaa')
print(b01)